package com.bxg.setDemo;

import com.bxg.listDemo.Person;

import java.util.Comparator;
import java.util.TreeSet;

/*
* TreeSet 排序
* 两种方式:
*    1.自然排序
* */
public class Demo3 {
    public static void main(String[] args) {
        TreeSet<Person> treeSet=new TreeSet<>(new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o2.getSalary()-o1.getSalary();
            }
        });
        treeSet.add(new Person("admin",25000));
        treeSet.add(new Person("java",35000));
        treeSet.add(new Person("php",15000));
        treeSet.add(new Person("python",16000));
        System.out.println(treeSet);//从小到大排序
    }

}
